import React, {Component} from 'react';
import BaseOpts from '../BaseOpts';
import './index.css';
import {InputNumber, Slider, Radio, Select, Upload, Icon, Checkbox} from 'antd';
import SlideInput from '../../common/SlideInput/index';

const RadioGroup = Radio.Group;


class HomeCatListOpts extends BaseOpts {

    static defaultProps = {
        data: {
            style: {},
            dataset: {},
            layout: {
                columnNum: 5
            }
        }
    };

    constructor(props) {
        super(props);

        this.state = {
            data: props.data
        };

    }

    render() {
        var {style, dataset, layout} = this.state.data;
        var marginBottom = parseFloat(style.marginBottom || 0);
        var marginTop = parseFloat(style.marginTop || 0);
        var columnNum = (layout ? layout.columnNum : 5) || 5;
        var shape = (layout ? layout.shape : 0) || 0;

        return (
            <div className="optsPanel">

                <div className="optsPanel__item">
                    <label className="optsPanel__item__hd">每行摆放</label>
                    <div className="optsPanel__item__bd">
                        <RadioGroup onChange={(e) => {
                            this.$dataChange('columnNum', e.target.value, 'layout');
                        }} defaultValue={columnNum}>
                            <Radio value={5}>5个</Radio>
                            <Radio value={4}>4个</Radio>
                            <Radio value={3}>3个</Radio>
                        </RadioGroup>
                    </div>
                </div>

                <div className="optsPanel__item">
                    <label className="optsPanel__item__hd">图标圆角</label>
                    <div className="optsPanel__item__bd">
                        <RadioGroup onChange={(e) => {
                            this.$dataChange('shape', e.target.value, 'layout');
                        }} defaultValue={shape}>
                            <Radio value={0}>圆形</Radio>
                            <Radio value={1}>方形</Radio>
                            <Radio value={2}>圆角</Radio>
                        </RadioGroup>
                    </div>
                </div>

                <div className="optsPanel__item">
                    <label className="optsPanel__item__hd">上外边距</label>
                    <div className="optsPanel__item__bd">
                        <SlideInput step={1} min={0} max={100} value={marginTop} onChange={(val) => {
                            this.$dataChange('marginTop', val + 'px', 'style');
                        }}/>
                    </div>
                </div>

                <div className="optsPanel__item">
                    <label className="optsPanel__item__hd">下外边距</label>
                    <div className="optsPanel__item__bd">
                        <SlideInput step={1} min={0} max={100} value={marginBottom} onChange={(val) => {
                            this.$dataChange('marginBottom', val + 'px', 'style');
                        }}/>
                    </div>
                </div>

                <div className="optsPanel__item">
                    <div className="optsPanel__item__bd">
                        <a href="/admin/HomeCatSetting/listPage?show_type=1" target="_blank"
                           className="ant-btn-dataMng ant-btn ant-btn-primary ant-btn-lg">数据管理</a>
                    </div>
                </div>

            </div>
        );
    }
}

export default HomeCatListOpts;
